{% extends 'TopxiaWebBundle:Announcement:announcement-modal-layout.html.twig' %}

{% set tab="manage" %}

{% block content %}
  <form id="announcement-write-form" class="form-horizontal" method="post"
    {% if announcement.id %}
      action="{{ path('announcement_update',{id:announcement.id, targetType:targetType,targetId:targetObject.id, }) }}"
    {% else %}
      action="{{ path('announcement_add',{targetType:targetType, targetId:targetObject.id}) }}"
    {% endif %}
  >

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="startTime">发布时间</label>
      </div>
      <div class="col-md-9 controls" style="z-index:2000;">
        <input type="text" id="startTime"  name="startTime" class="form-control" value="{% if announcement.startTime|default('now') %}{{announcement.startTime|default('now')|date("Y-m-d H:i")}}{% endif %}">
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="endTime">结束时间</label>
      </div>
      <div class="col-md-9 controls" style="z-index:2000;">
        <input type="text" id="endTime"  name="endTime" class="form-control" value="{% if announcement.endTime|default(null) %}{{announcement.endTime|date("Y-m-d H:i")}}{% endif %}">
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="content">公告内容</label>
      </div>
      <div class="col-md-9 controls">
        <textarea class="form-control" id="announcement-content-field" name="content" data-display="公告内容" data-image-upload-url="{{ path('editor_upload', {token:upload_token('default')}) }}">{{ announcement.content }}</textarea>
      </div>
    </div>

    {% if not announcement.id %}
    <div class="row form-group">
      <div class="col-md-2 control-label">
      </div>
      <div class="col-md-9 controls">
        <div class="checkbox">
          <label>
            <input type="checkbox" name="notify" value="notify"> 给{{ setting('default.user_name', '学员') }}发送系统通知
          </label>
        </div>
      </div>
    </div>
    {% endif %}
    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

  </form>

  <script>
    app.load('announcement/announcement-write');
  </script>

{% endblock %}
{% block footer %}
  <button type="button" class="btn btn-link" data-dismiss="modal">取消</button>
  <button type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#announcement-write-form">保存</button>
{% endblock %}